<template>
  <div>
    <van-nav-bar title="視頻列表" />
    <van-tabs :active="active">
      <van-tab title="亞洲"></van-tab>
      <van-tab title="歐洲"></van-tab>
      <van-tab title="南美洲"></van-tab>
      <van-tab title="北美洲"></van-tab>
      <van-tab title="大洋洲"></van-tab>
      <van-tab title="非洲"></van-tab>
       <van-tab title="澳洲"></van-tab>
        <van-tab title="双飞"></van-tab>
    </van-tabs>
    <van-search v-model="value" placeholder="请输入搜索关键词" shape="round"/>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <div v-for="(item,index) in videoList" :key="index" class="itemBox" @click="goInfo()">
            <img v-if="index<=9" :src="require('../../assets/img/0'+(index)+'.jpg')" alt="">
            <img v-else :src="require('../../assets/img/'+index+'.jpg')" alt="">
            <div class="videoName">致命的誘惑11</div>
        </div>
    </van-list>
  </div>
</template>

<script>
export default {
  name: "productList",
  components: {},
  created () {
    if(this.$route.params.index){
        this.active=this.$route.params.index
    }
  },
  data() {
    return {
      value:'',
      active: 0,
      videoList: [1, 1, 1, 1, 1,1,1],
      loading: false,
      finished: false,
    };
  },
   methods: {
       goInfo(item){
           this.$router.push({name:'videoInfo',query:{name:"精彩视频"}})
       },
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        for (let i = 0; i < 6; i++) {
          this.videoList.push(this.videoList.length + 1);
        }

        // 加载状态结束
        this.loading = false;

        // 数据全部加载完成
        if (this.videoList.length >= 20) {
          this.finished = true;
        }
      }, 1000);
    },
  },
};
</script>

<style lang="scss" scoped>
    .van-search__content{
        background-color: rgb(241, 237, 237);
    }
  .itemBox {
    display: inline-block;
    width: 44%;
    margin: 3%;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
    height: 200px;
    img{
        width:100%;
    }
    .videoName{
        font-size: 20px;
        text-align: center;

    }
  }
</style>